package com.huazi.www.frontdesk.servlet;

import com.alibaba.fastjson.JSON;
import com.huazi.www.frontdesk.service.impl.FrontdeskCardServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 转诊
 */

public class QueueTreatmentServlet extends HttpServlet {
    FrontdeskCardServiceImpl frontdeskCardService = new FrontdeskCardServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("utf-8");//修改request域的编码集
        resp.setContentType("text/thml;charse=UTF-8");//修改respones域的编码集
        resp.setCharacterEncoding("UTF-8");//修改respones域的编码集
        PrintWriter out = resp.getWriter();//创建输出对象
        String quiz1 = req.getParameter("quiz1");//获取传过来的quiz1
        Integer id = Integer.parseInt(req.getParameter("id"));//获取传过来的值 ids并转换为int类型
        boolean transfer = frontdeskCardService.transfer(quiz1, id);//new frontdeskCardService类transfer方法
        String istransfer = JSON.toJSONString(transfer);//转JSON

        out.println(istransfer);//输出到页面
        out.flush();//清空缓存区
        out.close();//关闭缓存区
    }

}
